package br.com.netomarin.bundesliga.persistence;

import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable 
public class Player {

	@PrimaryKey
	private String name;
	@Persistent
	private int points;
	@Persistent
	private int games;
	@Persistent
	private float average;
	@Persistent
	private int goalsScored;
	@Persistent
	private int goalsConceded;
	@Persistent
	private int ranking;
	@Persistent
	private int wins;
	@Persistent
	private int winsInARow;
	@Persistent
	private int losses;
	@Persistent
	private int lossesInARow;
	@Persistent
	private int draws;
	
	public Player() {}
	
	public Player(String token) {
		this.name = token;
	}

	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public int getPoints() {
		return points;
	}
	
	public void setPoints(int points) {
		this.points = points;
	}
	
	public void addPoints(int pointsToAdd) {
		this.points += pointsToAdd;
	}
	
	public int getGames() {
		return games;
	}
	
	public void setGames(int games) {
		this.games = games;
	}
	
	public float getAverage() {
		return average;
	}
	
	public void setAverage(float average) {
		this.average = average;
	}
	
	public int getGoalsScored() {
		return goalsScored;
	}
	
	public void setGoalsScored(int goalsScored) {
		this.goalsScored = goalsScored;
	}
	
	public void addGoalsScored(int goalsScored) {
		this.goalsScored += goalsScored;
	}
	
	public int getGoalsConceded() {
		return goalsConceded;
	}
	
	public void setGoalsConceded(int goalsConceded) {
		this.goalsConceded = goalsConceded;
	}
	
	public void addGoalsConceded(int goalsConceded) {
		this.goalsConceded += goalsConceded;
	}
	
	public int getRanking() {
		return ranking;
	}
	
	public void setRanking(int ranking) {
		this.ranking = ranking;
	}

	public int getWins() {
		return wins;
	}

	public void setWins(int wins) {
		this.wins = wins;
	}
	
	public void addWin() {
		this.wins++;
		this.winsInARow++;
		this.lossesInARow = 0;
	}

	public int getWinsInARow() {
		return winsInARow;
	}

	public void setWinsInARow(int winsInARow) {
		this.winsInARow = winsInARow;
	}

	public int getLosses() {
		return losses;
	}

	public void setLosses(int loses) {
		this.losses = loses;
	}
	
	public void addLoss() {
		this.losses++;
		this.lossesInARow++;
		this.winsInARow = 0;
	}

	public int getLosesInARow() {
		return lossesInARow;
	}

	public void setLosesInARow(int losesInARow) {
		this.lossesInARow = losesInARow;
	}

	public int getDraws() {
		return draws;
	}

	public void setDraws(int draws) {
		this.draws = draws;
	}
	
	public void addDraw() {
		this.draws++;
		this.winsInARow = 0;
		this.lossesInARow = 0;
	}
		
	public void calculatePointsAverage() {
		this.average = (float)this.points/(float)this.games;
	}
}